/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package component.xml;

import java.io.FileOutputStream;
import java.io.FileWriter;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;

/**
 *
 * @author Administrator
 */
public class xmltest {
    public static void main(String[] args) throws Exception
    {
        
        // 第二种方式:创建文档并设置文档的根元素节点
        Element root = DocumentHelper.createElement(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("采场"));
        Document document2 = DocumentHelper.createDocument(root);

        // 添加属性
        root.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("MINGCHENG"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("焦煤集团赵固一矿"));
        root.addText(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("这是我ROOT的TEXT"));
        // 添加子节点:add之后就返回这个元素
        Element gongzuomianElement = root.addElement(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("工作面"));
        gongzuomianElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("MINGCHENG"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("12041工作面底板注浆加固孔布置图"));
        gongzuomianElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("ZHITU"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("张三"));
        gongzuomianElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("制图日期"), String.valueOf(System.currentTimeMillis()));
        gongzuomianElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("HEDUI"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("李四"));
        gongzuomianElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("BILICHI"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("1:1000"));
        gongzuomianElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("KEZHANG"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("王五"));
        gongzuomianElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("BIANHAO"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("JZJJG-12041-11"));
        gongzuomianElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("GONGCHENGSHI"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("周六"));
        gongzuomianElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("CAICHANG"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("焦煤集团赵固一矿"));
        gongzuomianElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("GZMCD"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("176.76"));
        gongzuomianElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("GZMZXCD"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("800"));
        gongzuomianElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("GZMGSZBX"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("3919294"));
        gongzuomianElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("GZMGSZBY"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("38464379"));
        gongzuomianElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("GZMFWJ"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("95.59"));
        ////胶带顺槽10#钻场////
        Element zuanchangElement=gongzuomianElement.addElement(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("钻场"));
        zuanchangElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("MINGCHENG"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("胶带顺槽10#钻场"));
        zuanchangElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("SHENDU"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString(""));
        zuanchangElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("XDZBX"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("0"));
        zuanchangElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("XDZBY"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("25.6"));
        zuanchangElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("GONGZUOMIAN"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("12041工作面底板注浆加固孔布置图"));
        zuanchangElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("CHUANGJIANRIQI"), String.valueOf(System.currentTimeMillis()));
        zuanchangElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("YANZHANXING"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("1"));
        zuanchangElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("KONGXILV"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("1"));
        //钻孔10-1//
        Element zuankongElement=zuanchangElement.addElement(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("钻孔"));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("MINGCHENG"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("10-1"));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("FANGWEIJIAO"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("260"));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("QINGJIAO"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("-30"));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("CHENGKONG"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("60"));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("ZHUJIANGQIAN"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("60"));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("SHUIYA"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("2.2"));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("KONGSHEN"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("135"));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("V"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("144.3"));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("NIANTU"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("31"));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("SHUINI"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("13.8"));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("ZHONGYA"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("13"));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("BEIZHU"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString(""));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("ZUANCHANG"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("胶带顺槽10#钻场"));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("BANJING"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString(""));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("CHONGHE"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("12"));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("GENGXIN"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("15"));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("KONGXILV"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("1"));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("JUNZHI"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("17"));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("YANZHANFANGXIANG"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("4"));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("YANZHANXING"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("1"));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("CHUANGJIANRIQI"), String.valueOf(System.currentTimeMillis()));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("CHUIZHIMIANJIAODU"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString(""));
        zuankongElement.addAttribute(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("ZONGXIANGMIANJIAODU"), java.util.ResourceBundle.getBundle("myproj/globalizefile").getString(""));

        // 输出到文件
        // 格式
        OutputFormat format = new OutputFormat(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("    "), true);// 设置缩进为4个空格，并且另起一行为true
        XMLWriter xmlWriter2 = new XMLWriter(
                new FileOutputStream(java.util.ResourceBundle.getBundle("myproj/globalizefile").getString("3DDB.XML")), format);
        xmlWriter2.write(document2);

        
    }
}
